package game;

import java.util.HashMap;
import java.util.Map;

import javax.swing.ImageIcon;

/**
 * 
 * @author Malik
 *
 */
public class ImageLoader {

	private static Map<String, ImageIcon> loadedImages = new HashMap<String, ImageIcon>();
	
	/**
	 * Loads an image from the given URL. If the image has been loaded before
	 * it is fetched from memory in stead.
	 * @param url
	 * @return
	 */
	public static ImageIcon loadImage(String url){
		if (!loadedImages.containsKey(url)){
			loadedImages.put(url, new ImageIcon(url));
		}
		return loadedImages.get(url);
	}
}
